﻿using ASPApiDemo.IService;
using ASPApiDemo.Model;
using ASPApiDemo.Repository;

namespace ASPApiDemo.Service
{
    public class UserService : IUserService
    {
        public async Task<List<UserVo>> Query()
        {
            //实例化仓储，从仓储中查询数据拿到实体模型，然后将实体模型转换为视图模型暴露出去
            var userRepository = new UserRepository();
            var users = await userRepository.Query();
            return users.Select(user => new UserVo
            {
                UserName = user.Name
            }).ToList();
        }
    }
}
